package db

const TableNameGoods = TablePrefix + "goods"

type Goods struct {
	BaseModel
	TypeID      uint    `gorm:"column:type_id;type:int(11);default:0;comment:类型id" json:"typeID" form:"typeID"`                  // 类型id
	Type        int     `gorm:"column:type;type:int(1);default:0;comment:1=官方发售,2=积分商城" json:"type" form:"type"`                 // 1=官方发售,2=积分商城
	Num         int64   `gorm:"column:num;type:int(11);default:0;comment:数量" json:"num" form:"num"`                              // 数量
	Remain      int64   `gorm:"column:remain;type:int(11);default:0;comment:剩余数量" json:"remain" form:"remain"`                   // 剩余数量
	RestrictNum int64   `gorm:"column:restrict_num;type:int(11);default:0;comment:限制购买数量" json:"restrictNum" form:"restrictNum"` // 限制购买数量
	Price       float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:单价" json:"price" form:"price"`                  // 单价
	Status      bool    `gorm:"column:status;type:tinyint(1);default:0;comment:开售,关闭" json:"status" form:"status"`               // 开售,关闭
	Name        *string `gorm:"column:name;type:varchar(255);comment:商品名称" json:"name" form:"name"`                              // 商品名称
	Img         *string `gorm:"column:img;type:varchar(255);comment:商品配图" json:"img" form:"img"`                                 // 商品配图
}

func (*Goods) TableName() string {
	return TableNameGoods
}

type GoodsHasOneType struct {
	Goods
	Types    Type                             `gorm:"foreignKey:ID;references:TypeID" json:"types"`
	GoodsPay []GoodsPayHaxOneType             `gorm:"foreignKey:GID;references:ID" json:"goodsPay"`
	Donate   []TypeCardDonateHaxOneTypeOfRole `gorm:"foreignKey:TypeID;references:TypeID" json:"donate"`
}
